{ open Parser }

rule token = parse
[' ' '\t' '\r' '\n'] 	{ token lexbuf } 	(* Whitespace *)
| ":" 	{ comment lexbuf } 	(* Comments changed *)
| '(' 	{ LPAREN } 	
| ')' 	{ RPAREN } 	(* punctuation *)
| '{' 	{ LBRACE } 
| '}' 	{ RBRACE }
| '!' 	{ EXC } 
| ',' 	{ COMMA } 
| ';' 	{ SEMI } 
| '~' 	{ NEG } 
| '+' 	{ PLUS } 
| '-'	{ MINUS }
| '*' 	{ TIMES } 
| "\""	{ QUOTE }
| '/' 	{ DIVIDE }
| '=' 	{ ASSIGN }
| '%'	{ MOD }
| "==" 	{ EQ }
| "!=" 	{ NEQ } 
| '<' 	{ LT }
| "<=" 	{ LEQ } 
| '>' 	{ GT }
| ">=" 	{ GEQ }
| '|' 	{ CNCT }   
| "->" 	{ REDGE } 
| "<-"	{ LEDGE } 
| "--" 	{ UEDGE }
| "["   {LBRACK}
| "]"   {RBRACK}
| "||"  {OR}
| "&&" 	{AND}
| '.' {DOT}
| "add"		{ ADD }
| "addBy"	{ ADDBY }
| "addFront"	{ ADDFRONT }
| "call"        { CALL }
| "set"         { SET }
| "addByFront"	{ ADDBYFRONT }
| "call"	{ CALL }
| "crawl"	{ CRAWL }
| "edge"	{ EDGE }
| "else" 	{ ELSE } 
| "for" 	{ FOR }
| "flt"		{ FLOAT }
| "from"	{ FROM }
| "in" 		{ IN } 
| "int" 	{ INT }
| "if" 		{ IF } 
| "node"	{ NODE }
| "opt"		{ OPT }
| "order"	{ ORDER }
| "out" 	{ OUT }
| "print"	{ PRINT }
| "queue"	{ QUEUE }
| "rule"	{ RULE }
| "str"		{ STR }
| "while" 	{ WHILE }
| "with"	{ WITH } 
| "$"		{ DOLR }
| "child"       { CHILD }
| "parent"      { PARENT }
| "inedges"   { INEDGES }
| "outedges"  { OUTEDGES }
| "inedge"      { INEDGE }
| "outedge"     { OUTEDGE }
| "innode"      { INNODE }
| "outnode"     { OUTNODE }

| eof 		{ EOF } 
| ['0'-'9']+ as lxm 			{ LITINT(int_of_string lxm) } 
| ['0'-'9']*'.'['0'-'9']+ as lxm	{ LITFLT(float_of_string lxm) }
| '\"' [^'\"']* '\"' as lxm		{ LITSTR(lxm) } 

| ['a'- 'z' 'A'-'Z']['a'-'z' 'A'-'Z' '0'-'9' '_']* as lxm { ID(lxm) }

| _ as char 	{ raise (Failure("illegal character " ^ Char.escaped char)) }

and comment = parse
":" { token lexbuf }
| _ { comment lexbuf }
